Options -Indexes
ServerSignature Off

# ── Security Headers ──────────────────────────────────────────
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-XSS-Protection "1; mode=block"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
    Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' https://translate.google.com https://translate.googleapis.com https://www.gstatic.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self'; frame-src https://translate.google.com; base-uri 'self'; form-action 'self'; frame-ancestors 'self'"
</IfModule>

# ── Block access to sensitive files ──────────────────────────
<FilesMatch "\.(sql|log|env|md|json|lock)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# ── Block direct access to includes ──────────────────────────
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^includes/ - [F,L]
    RewriteRule ^admin/includes/ - [F,L]
    RewriteRule ^assets/uploads/.*\.(php|phtml|phar|cgi|pl|asp|aspx|jsp)$ - [F,L,NC]
</IfModule>

# ── Browser Caching ───────────────────────────────────────────
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png  "access plus 1 month"
    ExpiresByType image/webp "access plus 1 month"
    ExpiresByType text/css   "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
</IfModule>

# ── Gzip Compression ─────────────────────────────────────────
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css application/javascript text/plain application/json
</IfModule>

# ── PHP Settings ─────────────────────────────────────────────
<IfModule mod_php7.c>
    php_value upload_max_filesize 2M
    php_value post_max_size 4M
    php_value max_execution_time 30
    php_flag display_errors Off
</IfModule>
